The present invention generally relates to program calls to system routines, and more particularly to profiling system calls.
Operating systems generally include routines for providing to application programs services such as forking a new process or allocating memory. While virtually indispensable for the functions provided by the application, system calls may create challenges for the other tools used by a program developer.
For example, programmers will sometimes use tools for debugging, instrumentation, etc. These tools generally provide an environment in which the program executes. The Object Code Translator (OCT) from Hewlett Packard Company, for example, provides a variety of functions such as translation of object code from one processor architecture to another, code optimization, and instrumentation of operating system calls.
One challenge for a tool such as OCT is that while the system call may produce the desired result from the standpoint of the application, the system call may produce undesired side-effects from the standpoint of the tool. For example, the UNIX system call, exec( ), may be called to overlay a new program. To avoid being overwritten with the new program, the tool must intercept the call so that it can be included in the overlay. The tool must therefore be programmed to take appropriate measures when these system calls are made.
Some tools intercept system calls by retaining continuous control of the application and trapping system calls. For example, each branch instruction is tested for whether it references a system call. This continuous monitoring introduces a large overhead in running the application in conjunction with the tool.
A method and apparatus that address the aforementioned problems, as well as other related problems, are therefore desirable.
In various embodiments, a method and apparatus are provided for managing operating system calls. In a computer system that includes a system vector and a first vector table, an alternative vector table is provided. The first vector table includes references to respective segments of operating system program code that are associated with operating system calls, and the alternative vector table includes references to one or more respective segments of wrapper program code associated with segments of operating system program code. The system vector is set to reference the first vector table or the alternative vector table at selected times during execution of a user program. Thus, segments of operating system code are executed in response to operating system calls made when the system vector references the first vector table, and segments of code referenced in the alternative vector table are executed when the system vector references the alternative vector table. By using an alternative vector table, the overhead normally associated with intercepting system calls is reduced.
It will be appreciated that various other embodiments are set forth in the Detailed Description and Claims which follow.